package j2se.hash;

/**
 * Created by jingqing.zhou on 2015/6/9.
 * 获取hash值的算法 FNV1 32位散列
 */
public class Test {

    /**
     *
     * @param key
     * @param prime 一个质数
     * @return
     */
    private static  int getHashVale(String  key ,int prime){
        int hash , i ;
        for(hash=key.length(),i=0;i<key.length();i++){
            hash += key.charAt(i);
        }
        return (hash%prime);
    }
    public static void main(String[] args) {
       int hash = getHashVale("zhoujq11235556",333);
        System.out.println("HASH is "+hash);
    }
}
